package top.dotgo.model.sys.bean;

import cn.hutool.core.bean.BeanUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import top.dotgo.model.IBaseBean;
import top.dotgo.model.sys.SysAccountEntity;
import top.dotgo.model.validate.CreateGroup;

import javax.validation.constraints.NotEmpty;
import java.io.Serializable;

/**
 * 账号表(SysAccount)对象bean
 *
 * @author jornl
 * @date 2020-04-15 10:21:18
 */
@Getter
@Setter
@Accessors(chain = true)
public class SysAccountBean extends SysAccountEntity implements IBaseBean<SysAccountEntity>, Serializable {

    /**
     * 手机号
     */
    @NotEmpty(message = "请输入手机号", groups = CreateGroup.class)
    private String mobile;
    /**
     * 用户名
     */
    @NotEmpty(message = "请输入登录用户名")
    private String userName;

    /**
     * 密码
     */
    @NotEmpty(message = "请输入登陆密码", groups = CreateGroup.class)
    private String password;
    /**
     * 用户真实姓名
     */
    @NotEmpty(message = "请输入真实姓名", groups = CreateGroup.class)
    private String realName;

    /**
     * 用户状态：0禁用，1正常
     */
    private Integer status = 1;

    public static SysAccountBean bean(SysAccountEntity entity) {
        SysAccountBean bean = new SysAccountBean();
        BeanUtil.copyProperties(entity, bean);
        //密码设置空
        bean.setPassword(null);
        return bean;
    }

    @Override
    public SysAccountEntity entity() {
        SysAccountEntity entity = new SysAccountEntity();
        BeanUtil.copyProperties(this, entity);
        return entity;
    }


}
